// Copyright (c) 2011 Blue Onion Software, All rights reserved
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Text;
using BlueOnionSoftware.Bloget;
using NUnit.Framework;

namespace BlogetTests
{
    [TestFixture]
    [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")]
    public class PingBackTests
    {
        [Test]
        public void DoPingBackRequest()
        {
            using (var memoryStream = new MemoryStream())
            {
                PingBackClient.PingBackRequest(memoryStream, new Uri("http://localhost/source"), new Uri("http://localhost/target"));
                memoryStream.Flush();
                var result = Encoding.UTF8.GetString(memoryStream.ToArray());
                result = result.Substring(1); // Remove BOM
                var methodCall = MetaWeblogTests.ParseMethodCall(result);
                Assert.AreEqual("pingback.ping", methodCall.Name);
            }
        }
    }
}